﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class gameUI : MonoBehaviour {


	public GameObject btnMenu = null;
	public GameObject menu = null;

	public GameObject reward=null;

	public Text score = null;

	public Text textReward = null;

	public GameObject guide = null;

    public GameObject btnStartGame = null;

    public GameObject chooseSpeed = null;


	private static gameUI instance = null;
	public static gameUI GetInstance()
	{
		return instance;
	}

	void Awake()
	{
		instance = this;
	}

	// Use this for initialization
	void Start () {
		


		menu.SetActive (false);
		btnMenu.SetActive (true);
		reward.SetActive (false);
	}



	public void ShowGuide( bool show)
	{
		if (show) {
		
			BaseGame.nowGame.Pause ();

		} else {
		
			BaseGame.nowGame.UnPause ();

		}

		guide.SetActive (show);

	}

	public void OnBtnMenu()
	{
		menu.SetActive (true);
		btnMenu.SetActive (false);

		// 暂停
		BaseGame.nowGame.Pause();

	}
		

	public void OnBtnGoOn()
	{
		menu.SetActive (false);
		btnMenu.SetActive (true);

		BaseGame.nowGame.UnPause ();
	}

	public void OnBtnBack()
	{
		menu.SetActive (false);
		btnMenu.SetActive (true);

		BaseGame.nowGame.Clear ();

		// 后退
		lessonUI.GetInstance().ShowLessonInfo();

		BaseGame.nowGame.UnPause ();

		reward.SetActive (false);
	}

	public void OnBtnReplay()
	{
		// 重玩
		BaseGame.nowGame.Replay();
//		SceneCreator.GetInstance().Replay();


		menu.SetActive (false);
		btnMenu.SetActive (true);
		reward.SetActive (false);
	}

	public void RefreshScore( int s, int total, bool white = false )
	{
		score.text = s + "/" + total;
		if (white)
			score.color = Color.white;
		else
			score.color = new Color (0.38f, 0.105f, 0.105f);
	}

	public void HideReward()
	{
		reward.SetActive (false);
	}

	public void Finish(int s)
	{
		reward.SetActive (true);
		textReward.text = "总共获得" + s + "个";
	}

    public void OnBtnStartGame()
    {
//        btnStartGame.SetActive(false);
        BaseGame.nowGame.OnBtnStartGame();
    }

    public void OnBtnMansuGame()
    {
        BaseGame.nowGame.gameObject.SetActive(true);
        BaseGame.nowGame.ReInit(true);
        chooseSpeed.SetActive(false);
    }

    public void OnBtnKuaisuGame()
    {
        BaseGame.nowGame.gameObject.SetActive(true);
        BaseGame.nowGame.ReInit(false);
        chooseSpeed.SetActive(false);
    }
}
